#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
    int x=0;char ch=getchar();
    while(!isdigit(ch)) ch=getchar();
    while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x;
}
int stk[20],tp;
inline void write(ll x,char y)
{
    if(!x) putchar('0');
    else
    {
        tp=0;
        while(x) stk[++tp]=x%10,x/=10;
        while(tp) putchar(stk[tp--]^48);
    }
    putchar(y);
}
const int N=1.5e5+10,M=N<<2,K=1010;
struct ok{
    int v;ll w;
    bool operator <(const ok &A) const{return w>A.w;}
};
int n,m,A,B,fa[N],dis[N];
int first[N],to[M],nxt[M],cnt;
bool vis[N];
ll ans[N];
queue<int>q;
vector<ok>edge[N];
priority_queue<ok>Q;
inline void Min(ll &x,ll y) {x=x>y?y:x;}
inline void inc(int x,int y) {nxt[++cnt]=first[x],to[cnt]=y,first[x]=cnt;}
void dfs(int x,int fr)
{
    fa[x]=fr;
    Min(ans[x],ans[fr]+A);
    Min(ans[x],ans[fa[fr]]+B);
    for(int i=first[x],v;i;i=nxt[i])
        if((v=to[i])!=fr) dfs(v,x);
}
void bfs(int S)
{
    for(int i=1;i<=n;i++) dis[i]=1e9;
    dis[S]=0,q.push(S);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(int i=first[x],v;i;i=nxt[i])
            if(dis[v=to[i]]>dis[x]+1) dis[v]=dis[x]+1,q.push(v);
    }
}
void Dij(int S)
{
    for(int i=1;i<=n;i++) ans[i]=1e18;
    ans[S]=0,Q.push((ok){S,0});
    while(!Q.empty())
    {
        int x=Q.top().v;
        Q.pop();
        if(vis[x]) continue;
        vis[x]=1;
        for(ok v:edge[x])
            if(ans[v.v]>ans[x]+v.w) ans[v.v]=ans[x]+v.w,Q.push((ok){v.v,ans[v.v]});
    }
}
int main()
{
    freopen("edge.in","r",stdin);
    freopen("edge.out","w",stdout);
    n=read(),m=read(),A=read(),B=read();
    for(int i=1,u,v;i<=m;i++)
        u=read(),v=read(),inc(u,v),inc(v,u);
    memset(ans,0x3f,sizeof(ans));
    ans[1]=0;
    if(m==n-1) dfs(1,0);
    else
    {
        for(int i=1;i<=n;i++)
        {
            bfs(i);
            for(int j=1;j<=n;j++)
                if(dis[j]==1) edge[i].push_back((ok){j,A});
                else if(dis[j]==2) edge[i].push_back((ok){j,B});
        }
        Dij(1);
    }
    for(int i=2;i<=n;i++) write(ans[i],'\n');
    return 0;
}